import os
import sys
def to_mp4(dir,max):
    print("[+] 合成中...")
    file_name ="./videos/%s.mp4"%dir
    with open(file_name,'wb') as mp4:
        for i in range(0,max):
            with open("./videos/%s/%d.ts"%(dir,i),'rb') as ts:
                mp4.write(ts.read())
            os.remove("./videos/%s/%d.ts"%(dir,i))
    print("[+] 合成完毕，路径：%s"%file_name)


if __name__ == "__main__":
    try:
        to_mp4(sys.argv[1],int(sys.argv[2]))
    except:
        pass